<?php
  if(!$_COOKIE['UserID']){
    HEADER("location:./login.html");
  }
  include "../php/pdo-plus/src/PDO.class.php";
  include "../php/fn.php";
  include "../php/config.php";
  $db=DB::getInstance($database);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>寓萌</title>
<link rel="stylesheet" href="../layui/css/layui.css" />
<script src="../layui/layui.js"></script>
<style type="text/css">
.ys08 {	text-align: left;
}
#RadioGroup1_0 {
	text-align: left;
}
.ys03 {
	text-align: left;
}
.ys031 {font-size: 24px;
	font-weight: bold;
}
.ys01 {font-size: 24px;
}
.ys01 {font-size: 36px;
}
.ys01 {font-size: 14px;
}
.ys01 {font-size: 12px;
}
</style>
</head>

<body>
<table width="100%" border="0" align="center">
  <tr>
    <th height="40" scope="col"><table width="40%" border="1" align="right">
      <tr bgcolor="#9ABA78">
        <th scope="col">用户名</th>
        <th scope="col"><a href="寓萌-个人中心.html">个人中心</a></th>
        <th scope="col">公告</th>
        <th scope="col">关于我们</th>
        <th scope="col">系统消息</th>
        <th scope="col">退出</th>
      </tr>
    </table></th>
  </tr>
</table>
<table width="100%" border="0" align="center">
  <tr>
    <th width="90%" height="560" scope="col"><table width="100%" border="0" align="center">
      <tr>
        <th scope="col"><table width="1000" border="0" align="center">
          <tr>
            <th width="10%" height="40" bgcolor="#FF9966" scope="col"><a href="./list.php">首页</a></th>
            <th width="10%" height="40" bgcolor="#FF9966" scope="col"><a href="./addfang.php">新增房源</a></th>
                <th width="10%" height="40" bgcolor="#FF9966" scope="col"><a href="./list.php">房源</a></th>
            <th height="40" bgcolor="#FF9966" scope="col"><table width="40%" border="0" align="right">
              <tr>
                <th bgcolor="#00FFFF" scope="col">房源</th>
                <th bgcolor="#00FFFF" scope="col">推广</th>
                <th bgcolor="#00FFFF" scope="col">采购</th>
                <th bgcolor="#00FFFF" scope="col">融资</th>
                <th bgcolor="#00FFFF" scope="col">权限</th>
                <th scope="col">&nbsp;</th>
              </tr>
            </table></th>
          </tr>
        </table></th>
      </tr>
    </table>























        <div class="main" style="width:1000px;margin:10px auto;text-align: left;">
          <form class="layui-form" action="">
            <div class="layui-form-item">
              <label class="layui-form-label">*房屋管理人</label>
              <div class="layui-input-block">
                <input type="radio" name="owner" value="0" title="本人" checked>
                <input type="radio" name="owner" value="1" title="同事">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">*出租方式</label>
              <div class="layui-input-block">
                <input type="radio" name="zutype" value="2" title="整租">
                <input type="radio" name="zutype" value="1" title="合租">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">*靠近地铁</label>
              <div class="layui-input-block">
                <input type="radio" name="zutype" value="0" title="否">
                <input type="radio" name="zutype" value="1" title="是">
              </div>
            </div>
              <style>
                .left{
                  float: left;
                }
                .layui-inputarea .layui-input-inline:not(.select){
                  width:88px!important;
                }
              </style>
            <div class="layui-form-item">
              <label class="layui-form-label">房屋地址</label>
              <div class="layui-inputarea left">
                  <div class="layui-input-inline">
                    <select name="zoneid" lay-verify="required">
                        <?php
                            $zones=$db->query("select * from zones");
                            foreach ($zones as $key => $value) {
                                ?>
                        <option value="<?php echo $value['id'];?>"><?php echo $value['name'];?></option>

                                <?php
                            }
                        ?>
                      </select>
                  </div><div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">区</div>
                  <div class="layui-input-inline">
                    <input type="text" name="xiaoqu" required  lay-verify="required" placeholder="小区" autocomplete="off" class="layui-input">
                  </div><div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">小区</div>
                  <div class="layui-input-inline">
                    <input type="text" name="lou" required  lay-verify="required" placeholder="楼号" autocomplete="off" class="layui-input">
                  </div><div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">号楼</div>
                  <div class="layui-input-inline">
                    <input type="text" name="danyuan" required  lay-verify="required" placeholder="单元" autocomplete="off" class="layui-input">
                  </div><div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">单元</div>
                  <div class="layui-input-inline">
                    <input type="text" name="fanghao" required  lay-verify="required" placeholder="房间" autocomplete="off" class="layui-input">
                  </div><div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">房间</div>
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">房屋类型</label>
              <div class="layui-inputarea left">
                  <div class="layui-input-inline">
                    <input type="text" name="shi" required  lay-verify="required" placeholder="室" autocomplete="off" class="layui-input">
                  </div><div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">室</div>
                  <div class="layui-input-inline">
                    <input type="text" name="ting" required  lay-verify="required" placeholder="厅" autocomplete="off" class="layui-input">
                  </div><div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">厅</div>
                  <div class="layui-input-inline">
                    <input type="text" name="chu" required  lay-verify="required" placeholder="厨" autocomplete="off" class="layui-input">
                  </div><div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">厨</div>
                  <div class="layui-input-inline">
                    <input type="text" name="wei" required  lay-verify="required" placeholder="卫" autocomplete="off" class="layui-input">
                  </div><div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">卫</div>
                  <div class="layui-input-inline">
                    <input type="text" name="mianji" required  lay-verify="required" placeholder="面积" autocomplete="off" class="layui-input">
                  </div><div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">㎡</div>
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">朝向</label>
              <div class="layui-input-inline">
                <select name="chaoxiang" lay-verify="required">
                  <option value="0">无</option>
                  <option value="东">东</option>
                  <option value="南">南</option>
                  <option  value="西">西</option>
                  <option  value="北">北</option>
                  <option  value="南北">南北</option>
                  <option  value="东西">东西</option>
                  <option  value="东南">东南</option>
                  <option  value="西南">西南</option>
                  <option  value="东北">东北</option>
                  <option  value="西北">西北</option>
                </select>
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">装修</label>
              <div class="layui-input-inline">
                <select name="zhuangxiu" lay-verify="required">
                  <option value="0">无</option>
                  <option value="1">简装</option>
                  <option value="2">豪装</option>
                  <option value="3">精装</option>

                </select>
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">风格</label>
              <div class="layui-input-inline">
                <select name="fengge" lay-verify="required">
                  <option value="0">无</option>
                  <option value="经济适用">经济适用</option>
                  <option value="小资情调">小资情调</option>
                  <option value="富丽堂皇">富丽堂皇</option>

                </select>
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">楼层</label>
              <div class="layui-inputarea left">
                <div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">第</div>
                  <div class="layui-input-inline">
                    <input type="text" name="cengthis" required  lay-verify="required" placeholder="楼层" autocomplete="off" class="layui-input">
                  </div>
                  <div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">层</div>
                  <div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">共</div>
                  <div class="layui-input-inline">
                    <input type="text" name="cengall" required  lay-verify="required" placeholder="总楼层" autocomplete="off" class="layui-input">
                  </div><div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">层</div>

              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">*电梯</label>
              <div class="layui-input-block">
                <input type="radio" name="dianti" value="1" title="有电梯">
                <input type="radio" name="dianti" value="0" title="无电梯">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">*车位</label>
              <div class="layui-input-block">
                <input type="radio" name="chewei" value="1" title="有车位">
                <input type="radio" name="chewei" value="0" title="无车位">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">*租金</label>
              <div class="layui-inputarea left">

                  <div class="layui-input-inline">
                    <input type="text" name="price" required  lay-verify="required" placeholder="请输入租金" autocomplete="off" class="layui-input">
                  </div>
                  <div class="left" style="display: inline-block;float: left;line-height: 30px;padding:0 15px;">元/月</div>
                  <div class="layui-input-inline select">
                    <select name="paytype" lay-verify="required">
                      <option value="1">押一付一</option>
                      <option value="2">押一付三</option>
                      <option value="3">季付</option>
                      <option value="4">年付</option>

                    </select>
                  </div>

              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">租金包括</label>
              <div class="layui-input-block">
                <input type="checkbox" name="like[1]" title="水费">
                <input type="checkbox" name="like[2]" title="电费" checked>
                <input type="checkbox" name="like[3]" title="燃气费">
                <input type="checkbox" name="like[4]" title="取暖费">
                <input type="checkbox" name="like[5]" title="宽带费">
                <input type="checkbox" name="like[6]" title="物业费">
                <input type="checkbox" name="like[7]" title="停车费">
                <input type="checkbox" name="like[8]" title="有线电视费">
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">最早入住时间</label>
              <div class="layui-input-inline">
                <input type="text" name="starttime" id="test1" class="layui-input" />
              </div>
            </div>
            <div class="layui-form-item">
              <label class="layui-form-label">*看房方式</label>
              <div class="layui-input-block">
                <input type="radio" name="kanfang" value="1" title="房东有钥匙">
                <input type="radio" name="kanfang" value="2" title="密码锁">
                <input type="radio" name="kanfang" value="3" title="电话联系">
                <input type="radio" name="kanfang" value="4" title="其他">
              </div>
            </div>
            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label">房屋描述</label>
              <div class="layui-input-block">
                <textarea name="info" placeholder="请输入内容" class="layui-textarea"></textarea>
              </div>
            </div>
            <style>
                        .addimg{
                            border:2px dashed #c2c2c2;
                            width:250px;
                            height:136px;
                            text-align: center;
                            line-height: 136px;
                            font-size: 27px;
                            float: left;
                            margin: 0 10px 10px 0;
                            color:#c2c2c2;
                            cursor:pointer;
                            overflow: hidden;
                        }
                        .fangimg{
                            display: block;
                            height:136px;
                        }
                        .addimgspan{
                            font-size: 36px!important;
                            margin-right:5px;
                            color:#c2c2c2;
                        }
                </style>
            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label">房屋主图</label>
              <div class="layui-input-block">
                <div class="addimg main">
                    <span class="layui-icon addimgspan">&#xe64a;</span>添加图片
                </div>
              </div>
            </div>
            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label">房屋图片</label>
              <div class="layui-input-block">
                <div class="addimg">
                    <span class="layui-icon addimgspan">&#xe64a;</span>添加图片
                </div>
                <div class="addimg">
                    <span class="layui-icon addimgspan">&#xe64a;</span>添加图片
                </div>
                <div class="addimg">
                    <span class="layui-icon addimgspan">&#xe64a;</span>添加图片
                </div>
                <div class="addimg">
                    <span class="layui-icon addimgspan">&#xe64a;</span>添加图片
                </div>
                <div class="addimg">
                    <span class="layui-icon addimgspan">&#xe64a;</span>添加图片
                </div>
                <div class="addimg">
                    <span class="layui-icon addimgspan">&#xe64a;</span>添加图片
                </div>

              </div>
            </div>
            <input type="file" name="file" id="upimg" style="display: none;" />
            <div class="layui-form-item">
                <label class="layui-form-label">联系人</label>
                <div class="layui-input-inline">
                  <input type="text" name="contact" required  lay-verify="required" placeholder="联系人姓名" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-inline">
                  <input type="text" name="phone" required  lay-verify="required" placeholder="联系电话" autocomplete="off" class="layui-input">
                </div>
              </div>
              <!-- <div class="layui-form-item">
                <label class="layui-form-label">悬赏</label>
                <div class="layui-input-block">
                <input type="radio" name="悬赏" value="1" title="悬赏">
                <input type="radio" name="悬赏" value="0" title="不悬赏" checked>
              </div>
              </div> -->
              <div class="layui-form-item">
                <label class="layui-form-label">悬赏金额</label>
                <div class="layui-input-inline">
                  <input type="text" name="reward" required  lay-verify="required" placeholder="0" autocomplete="off" class="layui-input" value=0>
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">选取地址</label>
                <div class="layui-input-block">
                  <input type="hidden" name="x" value=0 id="posx">
                  <input type="hidden" name="y" value=0 id="posy">
                  <style>
                  #allmap {width: 100%;height: 500px;}
                  </style>
                  <div id="allmap"></div>
                </div>
              </div>
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
              </div>
            </div>
          </form>


        </div>

      <table width="100%" border="0">
        <tr>
          <th scope="col"><table width="1000" border="0" align="center">
            <tr>
              <th width="18%" height="200" scope="col"><table width="100%" border="0">
                <tr>
                  <th height="30" class="ys031" scope="col">用户帮助</th>
                </tr>
                <tr>
                  <th scope="row"><table width="100%" border="0">
                    <tr>
                      <th scope="col"><a href="https://www.dankegongyu.com/about/notice.html" target="_blank">入住指南</a></th>
                    </tr>
                    <tr>
                      <th scope="row"><a href="https://www.dankegongyu.com/zhuanti/20180111lifeHacks" target="_blank">生活常识</a></th>
                    </tr>
                    <tr>
                      <th scope="row"><a href="https://www.dankegongyu.com/about/problem.html" target="_blank">常见问题</a></th>
                    </tr>
                    <tr>
                      <th scope="row">&nbsp;</th>
                    </tr>
                  </table></th>
                </tr>
              </table></th>
              <th width="18%" height="200" scope="col"><table width="100%" border="0">
                <tr>
                  <th height="30" class="ys031" scope="col">商务合作</th>
                </tr>
                <tr>
                  <th scope="row"><table width="100%" border="0">
                    <tr>
                      <th scope="col"><a href="https://www.dankegongyu.com/zhuanti/20171219Styleforum" target="_blank">商务合作</a></th>
                    </tr>
                    <tr>
                      <th scope="row">&nbsp;</th>
                    </tr>
                    <tr>
                      <th scope="row">&nbsp;</th>
                    </tr>
                    <tr>
                      <th scope="row">&nbsp;</th>
                    </tr>
                  </table></th>
                </tr>
              </table></th>
              <th width="18%" height="200" scope="col"><table width="100%" border="0">
                <tr>
                  <th height="30" class="ys031" scope="col">公司信息</th>
                </tr>
                <tr>
                  <th scope="row"><table width="100%" border="0">
                    <tr>
                      <th scope="col"><a href="https://www.dankegongyu.com/about/aboutus.html" target="_blank">关于我们</a></th>
                    </tr>
                    <tr>
                      <th scope="row"><a href="https://www.dankegongyu.com/about/contact.html" target="_blank">联系我们</a></th>
                    </tr>
                    <tr>
                      <th scope="row">加入我们</th>
                    </tr>
                    <tr>
                      <th scope="row">&nbsp;</th>
                    </tr>
                  </table></th>
                </tr>
              </table></th>
              <th width="18%" height="200" scope="col"><table width="100%" border="0">
                <tr>
                  <th height="30" class="ys031" scope="col">客服热线</th>
                </tr>
                <tr>
                  <th scope="row"><table width="100%" border="0">
                    <tr>
                      <th scope="col">0311-5555555</th>
                    </tr>
                    <tr>
                      <th scope="row">工作日 09:00-21:00</th>
                    </tr>
                    <tr>
                      <th scope="row">&nbsp;</th>
                    </tr>
                    <tr>
                      <th scope="row">&nbsp;</th>
                    </tr>
                  </table></th>
                </tr>
              </table></th>
              <th height="200" scope="col"><table width="100%" border="1">
                <tr>
                  <th scope="col">APP二维码</th>
                  <th scope="col">公众号二维码</th>
                </tr>
              </table></th>
            </tr>
          </table></th>
        </tr>
    </table>
      <table width="100%" border="0" align="center">
        <tr>
          <th scope="col"><table width="1000" border="0" align="center">
            <tr>
              <th width="20%" height="80" scope="col">logl</th>
              <th height="80" scope="col"><table width="90%" border="0">
                <tr>
                  <th class="ys01" scope="col">北京自如信息科技有限公司 Copyright@2018 ziroom.com 版权所有 京ICP备16015349号-1</th>
                </tr>
                <tr>
                  <th class="ys01" scope="row">本网站所有页面的数据统计均来源于自如数据库   联系客服：自如客微信 周一至周日09:00-22:00</th>
                </tr>
              </table></th>
              <th width="15%" height="80" scope="col">行业标志认证</th>
            </tr>
          </table></th>
        </tr>
    </table></th>
  </tr>
</table>
</body>
</html>
<script src="../js/jquery-3.2.1.min.js"></script>
 <script>
          //Demo
          layui.use('form', function(){
            var form = layui.form;

            //监听提交
            form.on('submit(formDemo)', function(data){
                console.log(data.field);
                console.log(JSON.stringify(data.field));
                var formdata=new FormData();
                formdata.append("type","addfang");
                for(var key in data.field){
                    console.log(key);
                    console.log(data.field[key]);
                    formdata.append(key,data.field[key]);
                }
                var mainimg=$(".fangimg:eq(0)").attr("imgsrc") || "";
                var imgs='[';
                for(var i=1;i<7;i++){
                    imgs+='"'+($(".fangimg").eq(i).attr("imgsrc")||"")+'",';
                }
                imgs=imgs.substr(0,imgs.length-1);
                imgs=imgs+"]";
                console.log(imgs);
                formdata.append("mainimg",mainimg);
                formdata.append("imgs",imgs);
                $.ajax({
                    url: '../php/api.php',
                    type: 'post',
                    dataType: 'json',
                    data: formdata,
                    processData: false,  // 不处理数据
                    contentType: false   // 不设置内容类型
                })
                .done(function(msg) {
                    if(msg.state==1){
                        window.location.href="./list.php";
                    }
                })
                .fail(function() {
                    console.log("error");
                })
                .always(function() {
                    console.log("complete");
                });


              return false;
            });
          });
          layui.use('laydate', function(){
              var laydate = layui.laydate;

              //执行一个laydate实例
              laydate.render({
                elem: '#test1' //指定元素
              });
            });
            document.getElementsByClassName("layui-form")[0].onsubmit=function(){
              return false;
            }
            $(".addimg").click(function(event) {
                upindex=$(this).index(".addimg");
                $("#upimg").click();
            });
            $("#upimg").change(function(){
                var file=$(this)[0].files[0];
                console.log(file);
                console.log(upindex);
                var formdata=new FormData();
                formdata.append("imgs",file);
                $.ajax({
                    url: '../php/upload.php',
                    type: 'post',
                    dataType: 'json',
                    data: formdata,
                    processData: false,  // 不处理数据
                    contentType: false   // 不设置内容类型
                })
                .done(function(msg) {
                    if(msg.state==1){
                        $(".addimg").eq(upindex).html("<img class='fangimg' imgsrc='"+msg.files[0]+"' src='../upload/"+msg.files[0]+"'>");
                    }
                })
                .fail(function() {
                    console.log("error");
                })
                .always(function() {
                    console.log("complete");
                });

            });
          </script>
              <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=  And6GUZycRHnhsEoTj19uT7L"></script>
<script type="text/javascript">
    // 百度地图API功能
    var map = new BMap.Map("allmap");
    map.centerAndZoom("石家庄",12);
    map.enableScrollWheelZoom(true);
    //单击获取点击的经纬度
    map.addEventListener("click",function(e){
        map.clearOverlays();
        // alert(e.point.lng + "," + e.point.lat);
        // var marker = new BMap.Marker(new BMap.Point(e.point.lng, e.point.lat));
        var point = new BMap.Point(e.point.lng, e.point.lat);
        $("#posx").val(e.point.lng);
        $("#posy").val(e.point.lat);
        // map.centerAndZoom(point, 15);
        var marker = new BMap.Marker(point);  // 创建标注
        map.addOverlay(marker);               // 将标注添加到地图中
        marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
    });
</script>